import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import util.*;

public class SgxHarami {

	private HashMap<String, Candle> candlesYtd;
	private HashMap<String, Candle> candlesToday;
	private HashMap<Candle, Candle> candlePairs;

	public SgxHarami(String filenameYtd, String filenameToday) {
		candlesYtd = new HashMap<String, Candle>();
		Util.readFile(filenameYtd, candlesYtd);
		candlesToday = new HashMap<String, Candle>();
		Util.readFile(filenameToday, candlesToday);
		
		candlePairs = Util.matchCandlePairs(candlesYtd, candlesToday);
		
		Iterator<Candle> iterYtd = candlePairs.keySet().iterator();
		while (iterYtd.hasNext()) {
			Candle candleYtd = iterYtd.next();
			Candle candleToday = candlePairs.get(candleYtd);

			float haramiRatio = candleYtd.getHaramiRatio(candleToday); 
			if (haramiRatio >= 2.5) {
				String paddedStockName = String.format("%1$-30s", candleYtd.getStockName());
			      DecimalFormat formatter = new DecimalFormat("#.#"); 
				System.out.println(paddedStockName + "\t" + formatter.format(haramiRatio));
			}
		}
	}
	
	public static void main(String[] args) {
		new SgxHarami(args[0], args[1]);
	}

}
